#!/bin/bash
set -e

source $(dirname $0)/version

cd $(dirname $0)/..

echo "Building binaries..."

mkdir -p bin

LINKFLAGS="-X main.AppVersion=$VERSION
           -X main.GitCommit=$COMMIT"

for arch in "amd64" "arm64"; do
    GOARCH="$arch" CGO_ENABLED=0 go build -ldflags "-s -w $LINKFLAGS" -o bin/vm-dhcp-controller-"$arch" ./cmd/controller
    GOARCH="$arch" CGO_ENABLED=0 go build -ldflags "-s -w $LINKFLAGS" -o bin/vm-dhcp-agent-"$arch" ./cmd/agent
    GOARCH="$arch" CGO_ENABLED=0 go build -ldflags "-s -w $LINKFLAGS" -o bin/vm-dhcp-webhook-"$arch" ./cmd/webhook
done
